var lm = {
	dummy : null
};

lm.googleMap = {
	dummy : null,
	search : { dummy : null	}
};

lm.googleMap.search.createAddressList = function(keyword){
	var search_array = new Array();
	
	var words = keyword.split(" ");
	// 단어 순서대로 루프를 돌면서
	// 지오코더에서 검색되는 가장 긴 주소열을 찾는다.
	for (var j = words.length; j > 0; j--) {
		var buffer = "";
		for (var k = 0; k < j; k++) {
			buffer = buffer + " " + words[k];
		} // for
		search_array.push(buffer);
	} // for j
	
	return search_array;
};

lm.googleMap.search.geocode = function(searchList, searchNo, callback) {
	// 지오코드 검색
	var geocoder = new google.maps.Geocoder();
	var address = searchList[searchNo].trim();
	console.debug("Geocode : " + address);
	if (geocoder) {
		geocoder.geocode({address : address}, function(result, status){
			if (status == google.maps.GeocoderStatus.OK) {				
				console.debug("Address[" + address + "] : " + result[0].geometry.location);
				console.debug("Short Name: " + result[0].address_components[0].short_name);
				console.debug("Long Name: " + result[0].address_components[0].long_name);
				//map.setCenter(result[0].geometry.location);
			} else {
				if (status == google.maps.GeocoderStatus.ZERO_RESULTS) {
					if (searchNo < searchList.length - 1) {
						lm.googleMap.search.geocode(searchList, searchNo + 1);
					} // if
				} else {
					console.debug("error : " + status);
				} // if
			} // if
		});
	} // if
}; // lm.googleMap.search.geocode